package com.yuwei.goods_detail

import android.annotation.SuppressLint
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.text.Editable
import android.text.TextWatcher
import android.view.View
import android.webkit.WebChromeClient
import android.webkit.WebResourceRequest
import android.webkit.WebView
import android.webkit.WebViewClient
import com.alibaba.android.arouter.facade.annotation.Autowired
import com.alibaba.android.arouter.facade.annotation.Route
import com.alibaba.android.arouter.launcher.ARouter
import com.bumptech.glide.Glide
import com.yuwei.base.RoutePath
import com.yuwei.common.mvi.BaseViewActivity
import com.yuwei.database.entity.GoodsEntityItem
import com.yuwei.goods_detail.databinding.ActivityWebViewBinding
import com.yuwei.goods_detail.databinding.ActivityWebViewBindingImpl

/**
 * 游戏鸿蒙-i视频-02-分享咨询V1.1-20250614-崔志彪
 */
@Route (path = RoutePath.GOODS_WEBVIEW)
class WebViewActivity : BaseViewActivity<ActivityWebViewBinding>() {
    @Autowired(name = "kf")
    lateinit var goodsEntityItem: GoodsEntityItem
    override fun initView() {
        ARouter.getInstance().inject(this)
        binding.goodsEt.addTextChangedListener(object : TextWatcher {
            override fun beforeTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) {

            }

            override fun onTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) {

            }

            override fun afterTextChanged(p0: Editable) {
                if (p0.isNotEmpty()){
                    binding.add.visibility = View.GONE
                    binding.btn.visibility = View.VISIBLE
                }else{
                    binding.add.visibility = View.VISIBLE
                    binding.btn.visibility = View.GONE
                }
            }
        })

            binding.btn.setOnClickListener {
                binding.textView19.visibility = View.VISIBLE
                binding.textView20.text = binding.goodsEt.text.toString()
                binding.textView20.visibility = View.VISIBLE
                Glide.with(this).load(R.drawable.a).circleCrop().into(binding.goodsUserIv)
                binding.goodsUserIv.visibility = View.VISIBLE
                binding.goodsEt.text.clear()
            }
        Glide.with(this).load(goodsEntityItem.goods_default_icon).into(binding.goodsIv)
        binding.goodsTv.text = goodsEntityItem.goods_desc
        binding.goodsPrice.text = "￥${ goodsEntityItem.goods_default_price }"
        binding.goodsKfBack.setOnClickListener {
            finish()
        }
    }

    override fun initData() {

    }


}